import { Button, Space } from 'ant-design-vue'
import { tableColumns, arrivalStatusObj } from './data'

export function useColumns(updateFunction: Function, detailFunction: Function, scanCodeFunction: Function) {
  const getColumns = (column, record) => {
    if (column.dataIndex === 'orderNumber') {
      return <span>A{record.orderNumber}</span>
    } else if (column.dataIndex === 'brandName') {
      return <span>{record.brandName}</span>
    } else if (column.dataIndex === 'warehouseName') {
      return <span>{record.warehouseName}</span>
    } else if (column.dataIndex === 'arrivalTotal') {
      return <span>{record.arrivalTotal}</span>
    } else if (column.dataIndex === 'remark') {
      return <span>{record.remark}</span>
    } else if (column.dataIndex === 'createTime') {
      return <span>{record.createTime}</span>
    } else if (column.key === 'action') {
      return (
        <Space>
          <Button type='link' onClick={() => detailFunction(record.code)} v-auth={['warehouse:arrival-order:detail']}>
            详情
          </Button>
          <Button type='link' onClick={() => updateFunction(record.code)} v-auth={['warehouse:arrival-order:edit']}>
            编辑
          </Button>
          {/*{record.warehouseScanStatus == 1 && (*/}
          {/*  <Button type='link' onClick={() => scanCodeFunction(record.code)}>*/}
          {/*    扫码*/}
          {/*  </Button>*/}
          {/*)}*/}
        </Space>
      )
    }
  }
  return {
    getColumns,
    tableColumns
  }
}
